home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / basic / ace_final.lha / ACE_GPL_Release / src / DP / test.b < prev   
Encoding:
Text File  |  1996-08-29  |  2.3 KB  |  135 lines

  1. {*
  2. ** Test of Double-Precision math library for ACE.
  3. ** 
  4. ** See comments in dp_main.s and dp_val.c for more.
  5. *}
  6.  
  7. #include "dp.h"
  8.  
  9. {* Preliminaries *}
  10.  
  11. Address d1,d2,d3,dr
  12. Longint n,n1,n2,nr
  13. Single s,sr
  14.  
  15. '..Open the DP libraries.
  16. If Not dp_open Then 
  17.   Print "Unable to open DP libraries!"
  18.   Stop
  19. End If
  20.  
  21. '..Allocate memory for DP variables.
  22. d = dp_new
  23. d1 = dp_new
  24. d2 = dp_new
  25. d3 = dp_new
  26. dr = dp_new
  27. If d = NULL Or d1 = NULL Or d2 = NULL Or dr = NULL Then
  28.   Print "Unable to allocate DOUBLE variables."
  29.   Stop
  30. End If
  31.  
  32. {* A bunch of tests *}
  33.  
  34. '..LONGINT <-> DOUBLE.
  35. n = 1234567
  36. dp_longint_to_double(dr,n)
  37. dp_double_to_longint(@nr,dr)
  38. Print "LONGINT <-> DOUBLE:";nr
  39.  
  40. '..SINGLE <-> DOUBLE.
  41. s = 56.75
  42. dp_single_to_double(dr,s)
  43. dp_double_to_single(@sr,dr)
  44. Print "SINGLE <-> DOUBLE:";sr
  45.  
  46. '..Make some of DP values we can use.
  47. dp_longint_to_double(d1,21&)
  48. dp_longint_to_double(d2,3&)
  49. dp_single_to_double(d3,-34.78)
  50. Print "d1 = 21  d2 = 3  d3 = -34.78"
  51.  
  52. '..Addition.
  53. dp_add(dr,d1,d2)
  54. dp_double_to_longint(@nr,dr)
  55. Print "d1+d2 ";nr
  56.  
  57. '..Subtraction.
  58. dp_sub(dr,d1,d2)
  59. dp_double_to_longint(@nr,dr)
  60. Print "d1-d2 ";nr
  61.  
  62. '..Multiplication.
  63. dp_mul(dr,d1,d2)
  64. dp_double_to_longint(@nr,dr)
  65. dp_double_to_single(@sr,dr)
  66. Print "d1*d2 ";nr;sr
  67.  
  68. '..Division.
  69. dp_div(dr,d1,d2)
  70. dp_double_to_longint(@nr,dr)
  71. dp_double_to_single(@sr,dr)
  72. Print "d1/d2 ";nr;sr
  73.  
  74. '..Exponentiation.
  75. dp_pow(dr,d1,d2)
  76. dp_double_to_longint(@nr,dr)
  77. dp_double_to_single(@sr,dr)
  78. Print "d1^d2 ";nr;sr
  79.  
  80. '..Comparison.
  81. dp_cmp(@nr,d1,d2)
  82. Print "d1<=>d2 ";nr
  83.  
  84. '..Absolute value.
  85. dp_abs(dr,d3)
  86. dp_double_to_single(@sr,dr)
  87. Print "ABS d3";sr
  88.  
  89. '..Negation.
  90. dp_neg(dr,d3)
  91. dp_double_to_single(@sr,dr)
  92. Print "-d3 ";sr
  93.  
  94. '..Least integer >= argument.
  95. dp_ceil(dr,d3)
  96. dp_double_to_longint(@nr,dr)
  97. Print "CEIL d3 ";nr
  98.  
  99. '..Largest integer <= argument.
  100. dp_floor(dr,d3)
  101. dp_double_to_longint(@nr,dr)
  102. Print "FLOOR d3 ";nr
  103.  
  104. '..Sin, cos, tan, natural log, exp, square root.
  105. dp_sin(dr,d1)
  106. dp_double_to_single(@sr,dr)
  107. Print "SIN d1 ";sr
  108.  
  109. dp_cos(dr,d1)
  110. dp_double_to_single(@sr,dr)
  111. Print "COS d1 ";sr
  112.  
  113. dp_tan(dr,d1)
  114. dp_double_to_single(@sr,dr)
  115. Print "TAN d1 ";sr
  116.  
  117. dp_log(dr,d1)
  118. dp_double_to_single(@sr,dr)
  119. Print "LOG d1 ";sr
  120.  
  121. dp_exp(dr,d1)
  122. dp_double_to_single(@sr,dr)
  123. Print "EXP d1 ";sr
  124.  
  125. dp_sqrt(dr,d1)
  126. dp_double_to_single(@sr,dr)
  127. Print "SQR d1 ";sr
  128.  
  129. dp_val(dr,"-12.5e2")
  130. dp_double_to_single(@sr,dr)
  131. Print "String Parse: ";sr
  132.  
  133. '..Clean up.
  134. dp_close
  135.